#include <stdio.h>
#include <stdlib.h>

int sum;
void vis(char **a, int r, int c, int r_l, int c_l)
{
    if (!(r >= 0 && r < r_l && c >= 0 && c < c_l))
        return;
    if (a[r][c] != 1)
        return;
    a[r][c] = 2;
    sum++;
    printf("%d ", sum);
    vis(a, r + 1, c, r_l, c_l);
    vis(a, r - 1, c, r_l, c_l);
    vis(a, r, c + 1, r_l, c_l);
    vis(a, r, c - 1, r_l, c_l);
}

int maxAreaOfIsland(int **grid, int gridSize, int *gridColSize)
{
    //printf("%d %d %d",gridSize,gridColSize,grid[0][15]);
    int max = 0;
    for (int i = 0; i < gridSize; i++)
    {
        for (int j = 0; j < gridColSize[0]; j++)
        {
            if (grid[i][j] == 1)
            {
                sum = 0;
                vis(grid, i, j, gridSize, gridColSize[0]);
                if (sum > max)
                    max = sum;
            }
        }
    }
    return max;
}

int main()
{
    /*******************code*******************/

    /******************************************/
    fflush(stdin);

    printf("\n\n****************************\n");
    printf("Press Enter key to continue\n");
    getchar();
    return 0;
    /******************************************/
}
